package utils;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

public abstract class ExtendedListAdapter<T> extends ArrayAdapter<T> {
	
	private Context context;
	private int layout;
	private List<T> objects;

	public ExtendedListAdapter(Context context, int layout, List<T> objects) {
		super(context, layout, objects);
		this.context=context;
		this.layout=layout;
		this.objects=objects;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(layout, parent, false);
		T object=objects.get(position);
		display(object,rowView);
		return rowView;
	}

	protected abstract void display(T object, View rowView);

}
